package cs.rsa.ts14.circuitbreaker.states;

import cs.rsa.ts14.circuitbreaker.CircuitBreaker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Closed extends CircuitBreakerState {
    Logger logger = LoggerFactory.getLogger(Closed.class);
	public Closed(CircuitBreaker circuitBreaker)  {
		super(circuitBreaker);
        circuitBreaker.resetFailureCount();
        logger.info("closed");
    }
 
	@Override
    public void exceptionOccurred(Exception e) {
        super.exceptionOccurred(e);
        if (circuitBreaker.thresholdReached()) 
        	circuitBreaker.moveToOpenState();
    }
}
